package com.quick.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.quick.base.Page;
import com.quick.base.Search;
import com.quick.love.pojo.LoveUser;
import com.quick.love.search.LoveUserSearch;
import com.quick.love.vo.LoveUserVo;
import com.quick.mapper.LoveUserMapper;
import com.quick.service.ILoveUserService;
import com.quick.util.PageUtil;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoveUserServiceImpl implements ILoveUserService {

    private final LoveUserMapper loveUserMapper;

    public LoveUserServiceImpl(LoveUserMapper loveUserMapper) {
        this.loveUserMapper = loveUserMapper;
    }

    @Override
    public Page<LoveUserVo> search(Search<LoveUserSearch> search) {
        PageHelper.startPage(search.getPageNum(), search.getPageSize());
        QueryWrapper<LoveUser> queryWrapper = new QueryWrapper<>();
        List<LoveUser> userList = loveUserMapper.selectList(queryWrapper);
        PageInfo<LoveUser> pageInfo = new PageInfo<>(userList);
        return PageUtil.page(pageInfo,LoveUser.class);
    }
}
